package com.sc.nft.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.sc.nft.dao.ParticularsIdentityRightsDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.ParticularsIdentityRights;
import com.sc.nft.entity.dto.ParticularsIdentityRightsAdminModificationDTO;
import com.sc.nft.entity.vo.ParticularsIdentityRightsAdminVO;
import com.sc.nft.entity.vo.ParticularsIdentityRightsVO;
import com.sc.nft.enums.ParticularsIdentityRightsEnum;
import com.sc.nft.service.ParticularsIdentityRightsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * (ParticularsIdentityRights)表服务实现类
 *
 * @author 王伟成
 * @since 2024-03-09 15:03:36
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class ParticularsIdentityRightsServiceImpl implements ParticularsIdentityRightsService {

    private final ParticularsIdentityRightsDao particularsIdentityRightsDao;
    @Override
    public ParticularsIdentityRightsVO getType(ParticularsIdentityRightsEnum type) {
        ParticularsIdentityRights particularsIdentityRights = particularsIdentityRightsDao.getType(type);
        if (BeanUtil.isEmpty(particularsIdentityRights)) {
            return new ParticularsIdentityRightsVO();
        }
        return BeanUtil.copyProperties(particularsIdentityRights,ParticularsIdentityRightsVO.class);
    }
    @Override
    public List<ParticularsIdentityRightsAdminVO> list() {
        List<ParticularsIdentityRights> list = particularsIdentityRightsDao.list();
        return CollUtil.isEmpty(list) ? new ArrayList<>() : BeanUtil.copyToList(list, ParticularsIdentityRightsAdminVO.class);
    }
    @Override
    public void modification(ParticularsIdentityRightsAdminModificationDTO request) {
        ParticularsIdentityRights particularsIdentityRights = BeanUtil.copyProperties(request, ParticularsIdentityRights.class);
        particularsIdentityRightsDao.updateById(particularsIdentityRights);
    }
}
